package com.pc.controller;

import com.pc.enrty.Food;
import com.pc.enrty.Order;
import com.pc.enrty.Orderitems;
import com.pc.pojo.OrderItemsSet;
import com.pc.service.FoodService;
import com.pc.service.OrderItemsService;
import com.pc.service.OrderService;
import com.pc.util.ResultObject;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/orderitem/")
public class OrderitemsController {
    @Autowired
    private OrderItemsService orderItemsService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private FoodService foodService;
    @Autowired
    private ResultObject result;
    @RequestMapping("addOrderItems")
    public boolean addOrderItems(Orderitems orderitems){
        System.out.println(orderitems);
        ArrayList<Order> order = orderService.findOrder(new Order());
        int last = order.size()-1;
        orderitems.setOid(order.get(last).getId());//得到   oid
        boolean boo = orderItemsService.addOrderItems(orderitems);
        return boo;
    }
}
